Add a helper function for remote locations
authorMatthias Clasen <mclasen@redhat.com>
Fri, 24 Jul 2015 20:01:25 +0000 (16:01 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 27 Jul 2015 12:07:39 +0000 (08:07 -0400)
Add a helper function that says whether a location should be
considered remote. To determine this, we look at the filesystem
type reported by gvfs, and say 'remote' for sftp, webdav, ftp,
nfs and cifs.

gtk/gtkfilesystem.c
gtk/gtkfilesystem.h

index 772618f3d0ec23eb554adea73f8ac8ac2b626d12..baae74251d232c5559928fa257c5826040b70611 100644 (file)
@@ -921,3 +921,34 @@ _gtk_file_has_native_path (GFile *file)
 
   return has_native_path;
 }
+
+static const gchar * const remote_types[] = {
+  "sftp",
+  "webdav",
+  "ftp",
+  "nfs",
+  "cifs",
+  NULL
+};
+
+gboolean
+_gtk_file_consider_as_remote (GFile *file)
+{
+  GFileInfo *info;
+  gboolean is_remote;
+
+  info = g_file_query_filesystem_info (file, "filesystem::type", NULL, NULL);
+  if (info)
+    {
+      const gchar *type;
+
+      type = g_file_info_get_attribute_string (info, "filesystem::type");
+      is_remote = g_strv_contains (remote_types, type);
+
+      g_object_unref (info);
+    }
+  else
+    is_remote = FALSE;
+
+  return is_remote;
+}
index ebc796e19d78ea73791ca08a46ca2a3fdd022d32..70bd3eaaf1a1dab40e3ec2bfce1efb3db2792f0e 100644 (file)
@@ -118,6 +118,8 @@ gboolean    _gtk_file_info_consider_as_directory (GFileInfo *info);
 /* GFile helper functions */
 gboolean       _gtk_file_has_native_path (GFile *file);
 
+gboolean        _gtk_file_consider_as_remote (GFile *file);
+
 G_END_DECLS
 
 #endif /* __GTK_FILE_SYSTEM_H__ */